let userLoginVm = new Vue({
  el: "#appLogin",
  data: {
    user: {
      username: "",
      password: "",
    }
  },

  methods: {

    submit: function(){

      console.log(this.user.username);
      console.log(this.user.password);

      axios.post('/user/login', this.user).then(function(res){

        console.log('res = ' + res);
        if(res.data.code === 0){
          //将获取到的数据赋值给vm的user
          console.log('code = ' + res.data.code);
          userLoginVm.user = res.data.data;

          window.localStorage.setItem('username', userLoginVm.user.username);
          window.location.href = '/pages/index.html';
        }else{
          alert(res.data.message);
        }
      })
    },
  }

})